#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	string s;
	int z[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
    char m[11]={'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
	cin>>n;
	int k=n;
	for(int i=0;i<n;i++){
		int flag=0,sum=0;
		cin>>s;
		for(int j=0;j<17;j++){
			if(s[j]>='0'&&s[j]<='9'){
				sum+=(s[j]-'0')*z[j];
				
			}else{
				flag=1;
				break;
			}
		}
        if(flag==1||m[sum%11]!=s[17]){
			cout<<s<<endl;
			k--;
		}  
	}
	if(k==n) cout<<"All passed";
	return 0;
}
